import api from "./request";

// 检查关注状态
export const checkFollowStatus = (followerId: number, followeeId: number) => {
  return api.get("/api/follow/check-follow", {
    params: { followerId, followeeId }, // 使用查询参数
  });
};

// 关注用户
export const followUser = (followerId: number, followeeId: number) => {
  return api.post("/api/follow/follow", null, {
    params: {
      followerId,
      followeeId,
    },
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
  });
};

// 取消关注用户
export const unfollowUser = (followerId: number, followeeId: number) => {
  return api.post("/api/follow/unfollow", null, {
    params: {
      followerId,
      followeeId,
    },
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
  });
};

// 获取关注列表
export const getFollowUser = (followerId: number) => {
  return api
    .get("/api/follow/followees", {
      params: { followerId }, // 自动转为 URL Query 参数
      headers: {
        "Content-Type": "application/x-www-form-urlencoded",
      },
    })
    .then((res) => res.data);
};
